//
//  LGPatientDetailEvaluateCell.m
//  BreathTrainingTool
//
//  Created by 1234 on 2024/7/15.
//  患者详情-评估

#import "LGPatientDetailEvaluateCell.h"

@interface LGPatientDetailEvaluateCell()
/**   */
@property (nonatomic , strong)UILabel *titleLabel;
/**   */
@property (nonatomic , strong)UILabel *timeLabel;
/**   */
@property (nonatomic , strong)UILabel *scoreLabel;
/**   */
@property (nonatomic , strong)UIImageView *tipView;
@end

@implementation LGPatientDetailEvaluateCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return  self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    [super setDataDic:dataDic];
    self.titleLabel.text = (LGNSString(dataDic[@"questionTitle"]).length > 0)?LGNSString(dataDic[@"questionTitle"]):@" ";
    self.timeLabel.text = [NSString stringWithFormat:@"评估时间：%@",dataDic[@"createTime"]];
    self.scoreLabel.text = [NSString stringWithFormat:@"%@分",dataDic[@"score"]];
}

-(void)setType:(LGPositionType)type{
    [super setType:type];
    CGFloat titleTop = viewPix(6);
    CGFloat timeBottom = -viewPix(6);
    if (type == LGPositionTypeTop) {
        titleTop = viewPix(20);
        timeBottom = -viewPix(6);
    }else if (type == LGPositionTypeMiddle){
        titleTop = viewPix(6);
        timeBottom = -viewPix(6);
    }else if (type == LGPositionTypeBottom){
        titleTop = viewPix(6);
        timeBottom = -viewPix(20);
    }else{
        titleTop = viewPix(20);
        timeBottom = -viewPix(20);
    }
    [self.titleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(titleTop);
    }];
    [self.timeLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.contentView).offset(timeBottom);
    }];
}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.timeLabel];
    [self.contentView addSubview:self.scoreLabel];
    [self.contentView addSubview:self.tipView];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(viewPix(6));
        make.left.equalTo(self.contentView).offset(viewPix(32));
        make.right.lessThanOrEqualTo(self.scoreLabel.mas_left).offset(-viewPix(5));
    }];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLabel.mas_bottom).offset(viewPix(5));
        make.left.equalTo(self.titleLabel);
        make.bottom.equalTo(self.contentView).offset(-viewPix(6));
    }];
    [self.scoreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.tipView.mas_left).offset(-viewPix(2));
        make.centerY.equalTo(self.titleLabel);
    }];
    [self.tipView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).offset(-viewPix(32));
        make.centerY.equalTo(self.titleLabel);
        make.width.height.equalTo(@(18));
    }];
}

-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"" colorString:@"#2B2A37" textFont:LGFontWeight(15, UIFontWeightSemibold) textAlignment:NSTextAlignmentLeft lines:0];
    }
    return _titleLabel;
}

-(UILabel *)timeLabel{
    if(!_timeLabel){
        _timeLabel = [UILabel lableWithText:@"" colorString:@"#61616D" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _timeLabel;
}

-(UILabel *)scoreLabel{
    if(!_scoreLabel){
        _scoreLabel = [UILabel lableWithText:@"" colorString:kThemeColor textFont:LGFontWeight(17, UIFontWeightSemibold) textAlignment:NSTextAlignmentRight lines:1];
    }
    return _scoreLabel;
}

-(UIImageView *)tipView{
    if(!_tipView){
        _tipView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"themRightTip18"]];
    }
    return _tipView;
}

@end
